package com.skyinno.mrms;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.skyinno.mrms.conf.ApplicationConfiguration;



@SpringBootApplication

/**
 * 将应用的main类放到包的最上层，即root package，那么你就可以添加@ComponentScan注解而不需要任何参数，
 * 所有应用组件（@Component, @Service, @Repository, @Controller等）
 * 都会自动注册成Spring Beans(SpringBootApplication包含@ComponentScan)
 */


/**
 * 这个注解告诉Spring Boot根据添加的jar依赖猜测你想如何配置Spring。由于spring-boot-starter-web添加了Tomcat和Spring MVC，
 * 所以auto-configuration将假定你正在开发一个web应用，并对Spring进行相应地设置
 * @author ywhu
 *
 */

@EnableAutoConfiguration

/**
 * @Import注解可以用来导入其他配置类
 * @author ywhu
 *
 */
@Import({ApplicationConfiguration.class})
@EnableTransactionManagement//开启声明式事务的支持（默认为read-only模式）。但注意@Trancational注解
public class SpringBootWithHibernateApplication extends SpringBootServletInitializer {
    static Logger logger = LoggerFactory.getLogger(SpringBootWithHibernateApplication.class);

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootWithHibernateApplication.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SpringBootWithHibernateApplication.class, args);
    }
}
